package com.sohu.peak.gallery.dao.hibernate;

import java.util.List;

import org.hibernate.transform.ResultTransformer;

import com.sohu.peak.gallery.domain.Pic;
import com.sohu.peak.gallery.domain.PicGroup;

@SuppressWarnings("serial")
public class PicGroupResultTransformer implements ResultTransformer {

	public Object transformTuple(Object[] aobj, String[] as) {
		if(aobj!=null&&aobj.length>0&&aobj[0]!=null&&aobj[0] instanceof PicGroup){
			PicGroup picGroup = (PicGroup)aobj[0];
			if(aobj[1]!=null && aobj[1] instanceof Pic){
				PicGroup tmp = (PicGroup)picGroup.clone();
				tmp.setFirstPic((Pic)aobj[1]);
				return tmp;
			}else{
				return picGroup;
			}						
		}else{
			return null;
		}
	}
	
	@SuppressWarnings("unchecked")
	public List transformList(List list) {
		return list;
	}

}
